package com.dc.base.fiter;
import javax.servlet.*;
import java.io.IOException;

public class EncodingFilter {
    private String encoding=null;
    public void init(FilterConfig filterConfig) throws ServletException {
encoding=filterConfig.getInitParameter("encoding");
    }

    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        servletRequest.setCharacterEncoding("encoding");
        servletResponse.setCharacterEncoding("utf-8");
        servletResponse.setContentType("text/html;charset=utf-8");
        filterChain.doFilter(servletRequest,servletResponse);
    }

    public void destroy() {

    }
}
